* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

label {
    position: relative;
    width: 150px;
    height: 76px;
    background-color: #e9e9e9;
    border-radius: 38px;
    overflow: hidden;
}

label input {
    visibility: hidden;
    cursor: pointer;
}

label input::after {
    visibility: visible;
    /* 设置白色球 */
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 66px;
    height: 66px;
    background-color: #fff;
    border-radius: 50%;
    transition: all .5s;
}

/* 让复选框选中时候白球往右移动 */
label input:checked::after {
    transform: translateX(74px);
}

/* 设置复选框选中之后的背景颜色的改变 */
label input::before {
    visibility: visible;
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: all .5s;
}

label input:checked::before {
    background-color: #65c466;
}
